Hello and welcome.
In this lecture we are going to be creating the functionality for our to do app using javascript.
All right so we are in charge of our script file.
So we are going to be creating several functions inside these javascript file that will perform various
task.
The first punch function I am going to create here is going to fetch from the database the to dos and
that have already been defined.
All right so we're going to start there create a function was whose main task is to go to the database
and retrieve these to do lists that are in the database and we're going to implement this using local
storage because we are going to be storing the data inside our web browser.
Okay here is the function I have defined.
This function is going to be used by all the other functions that will be created later.
So what this function is going to do as you can see there's no parameters passed in the past in any
parameters.
The main purpose of this function is to fetch the content of the To Do list which would be a key in
the local storage.
So it would be use in the Get Out method which is this metate to retrieve the To Do list to to do items
that are inside this local storage.
So if this is the first time the function is called the specific local storage entry will probably be
empty.
Okay.
And the local storage get item called will return not that means it will return empty.
So life form here I've introduced a statement.
So basically what the statement is saying that if the return value is not not that is if it is not empty
then it must be the string.
The string of data which has been stored.
All right.
So the Jays sign here it goes on dog pass is used to convert the Jason's drink back in to Javascript
data that the browser can display.
The return here on Slide 7 is used to when you quit ifone change you can also specify a return value.
So if there's any data in the database this return value here will return the data that's in the local
storage.
So the function here you defined a function by type in the name function followed by the name you want
to give the function.
Giving it in name of get on does code to dos and line 2 and 3.
Basically variables have created line two variables to dos set it to cross to a new erry an array can
combine multiple variables has one line.
3 again created a variable code to dos underscore s t r we stansel String and I've set it to a local
storage.
Get high tech method unpassed it.
The to do.
Which is this variable here.
K.
Best blank line for.
So if the DOS list variable here is strictly as clear mentioned W was me strictly it is strictly not
empty then return.
Then you get this and convert it using this to javascript.
Okay pass this variable here and return wherever you finally did open the database.
That's what they're saying.
So I've created another function from line 10 to 20.
This function is called ADD.
Right.
So what the function will do.
The function is it will be called when the user of this it all clicks on the button.
So when the button is clicked on a tool Get it would trigger this.
Methods here.
Documento element.
And if it is passed in Tusk the task which is the value here.
It's well defined in the hastier mail which is this task here.
That's the idees talking about it to get dat.
And then add the value that has been imported.
So we use that and retrieve the value that the user has typed in.
All right.
So are we what.
What then does heat cause they get online 13 there.
It's called a variable called to do which is to get to dos.
So cause it get to dos we'd retrieve the already existing to do it from the database.
All right.
And then when and then it is appended to the Arey using the push method.
So does push met or it is used to append to it list that is added to your list.
Yes indeed.
Push medart to say for these variables add this method and any task that's been listed.
You add if there's any more task you need to add append it to the existing list.
So the push is used to add or add.
So once the new list is that pendent it is saved to a local story using the local store a set items
they don't set item is what is used to store it inside the local storage store to store that.
What we need to do first we use the string fi we have a string of five the three.
Okay so the Using the second string of 5 method.
What that does when we store enables us to store the returned string using the local storage set item
method.
I have called ifone John here.
Sure but we have not implemented written that function yet.
But this is where we also call the function from school.
Later on will write a function called show or notice.
Notice we've got a return value here called force.
So what that does.
It avoids any for their actions generated by the click event so even though the use of click it will
avoid any further action.
That's what that means.
What am going to do is split this show in two full javascript because he's gone on a bit long so I'm
going to stop this lecture here and will continue in part 2.
Thanks for watching.
Bye for now.